import { defineStore } from 'pinia'
import serverUrl from '../config/config.js'
import axios from 'axios'
const useNetStore = defineStore('net', {
  actions: {
    async fasong(data, typeRoute) {
      try {
        const res = await axios.post(serverUrl.serverUrl + typeRoute, data)
        return res.data
      } catch (err) {
        console.error(err)
        throw err
      }
    },
    async get(typeRoute) {
      try {
        const res = await axios.get(serverUrl.serverUrl + typeRoute)
        return res.data
      } catch (err) {
        console.error(err)
        throw err
      }
    }
  }
})

export default useNetStore
